
package com.be.beadmin.project.repository;

import com.be.beadmin.project.entity.Info;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author zmy
* @date 2023-01-13
**/
public interface InfoRepository extends JpaRepository<Info, String>, JpaSpecificationExecutor<Info> {

    Info findInfoByIdAndDelete(String id, Integer delete);


    Info findInfoByProjectNameAndDelete(String projectName,Integer delete);

    Info findInfoById(String id);

    Info findInfoByProjectCodeAndDelete(String projectCode, int i);


    List<Info> findInfosByTeamIdInAndDelete(List<String> teamIds, Integer delete);


    @Query(value = "select distinct i.id from t_pm_info i where i.team_id in ?1 and i.is_delete = ?2",nativeQuery = true)
    List<String> findUniqueInfoIdsByTeamIdInAndDelete(List<String> teamIds, Integer delete);

    Integer countInfoByDelete(int delete);

    Integer countInfoByContractStateAndDelete(String contractState, int delete);

    /**
     * 根据项目编码查询项目是否存在
     */
    Info findProjectByProjectCode(String projectCode);

    /**
     * 根据项目编码查询所有的信息
     * @param projectCode
     * @return
     */
    Info findInfoByProjectCode(String projectCode);

    List<Info> findInfosByDelete(Integer delete);

    Info findInfoByProjectCodeAndProjectNameAndDelete(String projectCode, String projectName, int delete);
}